package com.manage.controller;

import com.manage.service.StoreOrdersListService;
import com.manage.utils.FBJSONResult;
import com.manage.utils.PagedResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "有关商家订单管理的操作", tags = {"有关商家订单管理的操作"})
public class StoreOrdersListController {

    @Autowired
    private StoreOrdersListService storeOrdersListService;

    @ApiOperation(value = "商家订单管理信息查询(根据用户id)", notes = "商家订单管理信息查询(根据用户id)接口")
    @ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String", paramType = "query")
    @PostMapping("/storeOrder/queryStoreOrdersInfoByUserId")
    public FBJSONResult queryStoreOrdersInfoByUserId(Integer page, String userId) throws Exception {
        if(StringUtils.isBlank(userId)) {
            return FBJSONResult.errorMsg("用户id不能为空");
        }
        if(page == null) {
            page =1;
        }
        PagedResult result = storeOrdersListService.queryStoreOrdersInfoByUserId(page, 10, userId);
        return FBJSONResult.ok(result);
    }
}
